/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-02-15
 * Time: 23:33
 */
public class Testemo {
    public static void main(String[] args) {
        System.out.println("这里写Map刷题代码");

        //复制带随机指针的链表
        public Node copyRandomList(Node head) {
            if(head == null){
                return null;
            }
            Node cur = head;
            HashMap<Node,Node> map = new HashMap<>();
            while(cur!=null){
                map.put(cur,new Node(cur.val));
                cur = cur.next;
            }
            cur=head;
            while(cur!=null){
                map.get(cur).next=map.get(cur.next);
                map.get(cur).random=map.get(cur.random);
                cur=cur.next;
            }
            return map.get(head);
        }
    }
}
